#include "../tools.h"


class Solution {
public:
    bool Find(int target, vector<vector<int> > array) {
        int nrow = array.size(), ncol = array[0].size();
        if(nrow == 0 || ncol == 0) return false;

        int ro = 0, co = ncol - 1;
        while(ro < nrow && co > -1){
            if(array[ro][co] == target)
                return true;
            if(array[ro][co] > target)
                --co;
            else
                ++ro;
        }
        return false;
    }
};


int main(int argc, char const *argv[])
{
    vector<vector<int>> arr2d = {
        {1,2,8,9},
        {2,4,9,12},
        {4,7,10,13},
        {6,8,11,15}
    };
    int target = 3;

    Solution s;
    bool res = s.Find(target, arr2d);

    cout << res << endl;






    return 0;
}
